home *** CD-ROM | disk | FTP | other *** search
- property spriteNum, motion, undercard, location
- global shuffledCards, stock, foundation, tableau, equal, currentsel, godlist, getlist, points
-
- on beginSprite me
- shuffle()
- stock = new(script("card pile"))
- undercard = sprite(9)
- location = sprite(spriteNum).loc
- repeat while shuffledCards.count > 0
- sprite(spriteNum).member = member(shuffledCards[1].rank & "_" & shuffledCards[1].suit, "playing cards")
- shuffledCards.deleteAt(1)
- stock.addCard(spriteNum)
- end repeat
- end
-
- on shuffle me
- ranks = ["ace", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "jack", "queen", "king"]
- suits = ["hearts", "diamonds", "clubs", "spades"]
- unshuffledCards = []
- shuffledCards = []
- repeat with rank in ranks
- repeat with suit in suits
- unshuffledCards.add([#rank: rank, #suit: suit])
- end repeat
- end repeat
- repeat while unshuffledCards.count > 0
- shuffledCards.add(unshuffledCards[random(unshuffledCards.count)])
- unshuffledCards.deleteOne(shuffledCards[shuffledCards.count])
- end repeat
- end
-
- on mouseDown me
- if stock.getcardcount() > 0 then
- puppetSound(3, member("pick card", "100GPak Generic SFX"))
- sprite(spriteNum).locZ = spriteNum + 1000
- getlist = stock
- if stock.getcardcount() > 1 then
- undercard.member = member(stock.cards[stock.getcardcount() - 1].membername, "playing cards")
- else
- if stock.getcardcount() = 1 then
- undercard.member = member("empty", "playing cards")
- end if
- end if
- motion = timeout(string(spriteNum) && "motion").new(5, #moving, me)
- end if
- end
-
- on moving me
- if the mouseDown then
- sprite(spriteNum).loc = the mouseLoc
- else
- if the mouseUp then
- sprite(spriteNum).locZ = spriteNum
- motion.forget()
- abort()
- end if
- end if
- end
-
- on mouseUp me
- if equal then
- puppetSound(3, member("pick card", "100GPak Generic SFX"))
- sprite(currentsel).member = member(sprite(spriteNum).member.name, "playing cards")
- godlist.addCard(currentsel)
- sprite(spriteNum).loc = location
- stock.cards.deleteOne(stock.getlastcard())
- if objectp(foundation[sprite(currentsel).row]) then
- points = points + 10
- end if
- if objectp(tableau[sprite(currentsel).row]) then
- repeat with i = 71 to 74
- if tableau[sprite(i).row].getcardcount() = 0 then
- next repeat
- end if
- sprite(i).loc = tableau[sprite(i).row].getlastcard().location
- end repeat
- end if
- if stock.getcardcount() > 0 then
- sprite(spriteNum).member = member(stock.getlastcard().membername, "playing cards")
- else
- if stock.getcardcount() = 0 then
- sprite(spriteNum).member = member("empty", "playing cards")
- undercard.member = member("empty", "playing cards")
- end if
- end if
- equal = 0
- currentsel = 0
- godlist = VOID
- getlist = VOID
- checkwin()
- else
- if not equal then
- puppetSound(3, member("drop card", "100GPak Generic SFX"))
- getlist = VOID
- sprite(spriteNum).loc = location
- end if
- end if
- end
-